﻿using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;

namespace PInvokeDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            NativeMethods.MessageBoxA((IntPtr)null, "Hello Wolrd!", "Tip", 0);
            Console.ReadKey();
        }
    }

    internal static class NativeMethods
    {
        [DllImport("user32.dll", EntryPoint ="MessageBoxA")]
#pragma warning disable SYSLIB0003 // 类型或成员已过时
        [RegistryPermission(SecurityAction.Assert, Unrestricted = true)]
#pragma warning restore SYSLIB0003 // 类型或成员已过时
        internal static extern int MsgBox(
        IntPtr hWnd, string lpText, string lpCaption, uint uType);

        [DllImport("user32.dll")]
        internal static extern int MessageBoxA(
       IntPtr hWnd, string lpText, string lpCaption, uint uType);
    }
}
